package cn.com.infcn.spider.util;

import java.util.Map;

import org.nlpcn.commons.lang.util.StringUtil;
import org.nutz.lang.util.ByteInputStream;
import org.python.util.PythonInterpreter;

/**
 * runner a jython code
 * 
 * @author ansj
 * 
 */
public class JythonRunner {

	public static void run(Map<String, Object> map, String code) {

		if (StringUtil.isBlank(code)) {
			return;
		}

		PythonInterpreter interp = JythonFactory.newInstance(map);

		interp.execfile(new ByteInputStream(code.getBytes()));
	}
}
